Ext.define('xyc.view.PurchaseSumList', {
    extend: 'Ext.Panel',
    xtype: 'purchasesumlist',
    requires: [
        'xyc.model.Purchase'
    ],
    config: {
        layout: 'card',
        groupByDay: true,
        loadingText: '加载中...'
    },
    initialize: function () {
        this.callParent();
        this.searchstore = new Ext.data.Store({
            model: 'xyc.model.Purchase',
            autoLoad: true,
            sorters: '',
            proxy: {
                type: 'ajax',
                url: server + '/ext/com.cinsea.mobile.ext.XycAction?action=getpurchasesum',
                params: {type: '1'},
                reader: {
                    type: 'json',
                    totalProperty: 'totalCount',
                    rootProperty: 'result'
                }

            }
        })
        this.list = new Ext.List({
            id: 'purchases',
            itemTpl: '<span class="name">{place3}:{total} {num}</span>',
            loadingText: false,
            store: this.searchstore
        });

        this.listpanel = new Ext.Panel({
            items: this.list,
            layout: 'fit'
        });
        this.listpanel.refresh = function () {
            Ext.getCmp('purchases').getStore().load()
        }


        this.listpanel.add({
            xtype: 'toolbar',
            docked: 'top',
            layout: { pack: 'left' },
            items: [
                {
                    ui: 'back',
                    text: '返回',
                    scope: this,
                    handler: function () {
                        this.getParent().setActiveItem(this.prevCard, {
                            type: 'slide',
                            reverse: true,
                            scope: this,
                            after: function () {
                                this.destroy();
                            }
                        });
                    }
                }
            ]
        });

        // Take off the spinner
        //this.list.el.unmask();

        this.add(this.listpanel);

    },

    setPrevcard: function (prevc) {
        this.prevCard = prevc;
    }

});
